package com.atguigu.principle.demeter.improve;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

public class Demeter {
    public static void main(String[] args) {
        SchoolManager schoolManager = new SchoolManager();
        schoolManager.printAllEmployee(new CollegeManager());
    }
}

@Data
class Employee {
    private String id;
}

@Data
class CollegeEmployee {
    private String id;
}

class CollegeManager {
    public List<CollegeEmployee> getAllEmployee() {
        List<CollegeEmployee> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            CollegeEmployee emp = new CollegeEmployee();
            emp.setId("学院员工ID=" + i);
            list.add(emp);
        }
        return list;
    }

    public void printEmployee() {
        List<CollegeEmployee> list = getAllEmployee();
        System.out.println("-----学院员工-----");
        for (CollegeEmployee e : list) {
            System.out.println(e.getId());
        }
    }
}

class SchoolManager {
    public List<Employee> getAllEmployee() {
        List<Employee> list = new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            Employee emp = new Employee();
            emp.setId("学校总部员工ID=" + i);
            list.add(emp);
        }
        return list;
    }

    public void printAllEmployee(CollegeManager sub) {
        sub.printEmployee();

        List<Employee> list = this.getAllEmployee();
        System.out.println("-----学校总部员工-----");
        for (Employee e : list) {
            System.out.println(e.getId());
        }
    }
}
